import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
type parmas = {
    "goodsId": string,
    "paymentMethod": string
  }

type Rsponse = {
    code: string;
    message: string;
}

/** 创建和支付订单 */
export const apiPostCreatAndCheckoutOrder = async (parmas: parmas) => {
    const response: Rsponse = await sendRequest(parmas);
    return response;
};

const sendRequest = async (parmas: parmas) => {
    let response1: Rsponse;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: `order/create-and-checkout`,
            method: 'POST',
            data: parmas,
        });
    } else {
        response1 = {
            code: '200',
            message: 'ok',
        };
    }
    return response1;
};
